package com.xzy.custom;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.xzy.entities.Record;
import com.xzy.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/*
 * 操作日志工具类
 */
@Controller
public class LogUtils {

	@Autowired
	private RecordService service;
 
	public void log(String username, String op) {
		Record log = new Record();
		log.setUsername(username);
		log.setOperation(op);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat df2 = new SimpleDateFormat("HH:mm:ss");
		String date = df.format(new Date());
		String time=df2.format(new Date());
		log.setDate(date);
		log.setTime(time);
		service.save(log);
	}
}
